package com.soft.knowledge.service;

import com.soft.knowledge.entity.VoteExample;
import com.soft.knowledge.mapper.VoteMapper;
import com.soft.knowledge.req.VoteReq;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

import javax.annotation.Resource;

@Service
public class VoteService {
    @Resource
    private VoteMapper voteMapper;

    public boolean isVoted(VoteReq req){
        VoteExample example = new VoteExample();
        VoteExample.Criteria criteria = example.createCriteria();
        criteria.andInfoIdEqualTo(req.getInfoId())
                .andUserIdEqualTo(req.getUserId());

        return ObjectUtils.isEmpty(voteMapper.selectByExample(example));
    }
}
